<template>
	<view class="comNav">
		<!-- <scroll-view scroll-x class="nav text-left bg-white text-lg text-bold">
			<view class="cu-item" :class="index==TabCur?'text-orange cur':''" v-for="(item,index) in list" :key="index" @tap="tabSelect" :data-id="index">
				{{item}}
			</view>
		</scroll-view> -->
		<scroll-view scroll-x class="bg-white nav">
			<view class="flex text-center">
				<view class="cu-item flex-sub" :class="index==TabCur?'text-orange cur':''" v-for="(item,index) in list" :key="index" @tap="tabSelect" :data-id="index">
					{{item}}
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default{
		props:{
			list: {type: Array},
			value: {type: [String, Number]}
		},
		data() {
			return {
				TabCur: 0,
				scrollLeft: 0
			}
		},
		mounted() {
			this.init()
		},
		methods: {
			init() {
				console.log(this.value)
				this.tabCur = this.value
			},
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
				this.$emit("input", this.TabCur)
			}
		}
	}
</script>

<style lang="scss">
	.comNav{
		.cu-item{
			margin: 0 50rpx;
		}
	}
</style>
